package com.linciping.room.sample

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import kotlinx.coroutines.flow.Flow

@Dao
interface UserDao {

    @Query("select * from user")
    fun getAll(): Flow<MutableList<User>>

    @Query("select * from user where id=:userId LIMIT 1")
    fun getUserById(userId: Long): Flow<User>

    @Insert
    suspend fun insert(user: User): Long

    @Delete
    suspend fun delete(user: User): Int
}